home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (DO)
/
Nibble Volume 07, No. 06 (1986-06)(MicroSPARC)(Side A).zip
/
Nibble Volume 07, No. 06 (1986-06)(MicroSPARC)(Side A).do
/
MICROSCOPE.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
49KB
|
1,343 lines
*
***************************
* *
* MicroScope *
* by Ong Tee Yong *
* 7628C, Pantai Pringgit, *
* Melaka, Malaysia *
* *
* Copyright (C) 1986 *
* by MicroSPARC, Inc. *
* Concord, MA 01742 *
* *
***************************
* MERLIN ASSEMBLER
*
ORG $2000
*
TEMP EQU $19 ;Temporary work location
TEMPA EQU $1A ;Temporary work location
PTR EQU $1B ;Used in array listing rtn
LISTTEMP EQU $1D ;Location used in list rtn
VIDEOTMP EQU $1E ;Temporary storage for INVFLG
WNDTMP EQU $1F ;Store top line of scroll window
WNDS EQU $20 ;Left column of scroll window
WNDTOP EQU $22 ;Top line of scroll window
CH EQU $24 ;Cursor column
CV EQU $25 ;Cursor row
INVFLG EQU $32 ;Flag for nature of screen output
; Inverse, Flash, Normal
PROMPT EQU $33 ;Prompt character stored here
A1L EQU $3C ;MOVE start
A2L EQU $3E ;MOVE end
A4L EQU $42 ;MOVE destination
LINNUM EQU $50 ;Location of line no.
VARTBL EQU $69 ;Start of simple variable pointer
ARYTBL EQU $6B ;Pointer to start of array
VAREND EQU $6B ;End of simple variable pointer
ARYEND EQU $6D ;Pointer to end of array
HIMEM EQU $73 ;Applesoft Himem
CURLIN EQU $75 ;Current line no. being executed
OLDLIN EQU $77 ;Location to save line no. at
; which program halted
LOWTR EQU $9B ;Location used by FINDLIN rtn
FACMO EQU $A0 ;Mid. order byte of FAC mantissa
FACLO EQU $A1 ;Low order byte of FAC mantissa
TXTPTR EQU $B8 ;Text pointer address
STEPFLG EQU $CE ;Flag to indicate stepping mode
AUTOFLG EQU $CF ;Auto-stepping flag
CHTEMP EQU $D6 ;Storage for cursor column
CVTEMP EQU $D7 ;Temporary storage for cursor row
AHOLD EQU $EB ;Temporary storage for (A)
XREG EQU $EC ;Temporary storage for (X)
YREG EQU $ED ;Temporary storage for (Y)
STATUS EQU $EE ;Temporary storage for (P)
CONTFLG EQU $EF ;Program continuation flag
PRTFLG EQU $FA ;Line no. printing flag
NOWLNFLG EQU $FB ;Print line just executed flag
LINNOTMP EQU $FC ;Storage of current line no.
VRYTBL EQU $FE ;Temporary area used in variable
; and array listing rtn
BUFF EQU $200 ;Buffer used in array listing rtn
AMPER EQU $3F5 ;Holds jump instruction for & rtn
KEYBOARD EQU $C000 ;Keyboard input location
KBDSTRB EQU $C010 ;Clear keyboard strobe location
PGMSTP EQU $D43F ;Program stop rtn
GDBUFS EQU $D539 ;Zero buff. end, clear high bits
FINDLIN EQU $D61A ;Point LOWTR to line in LINNUM
INCPTR EQU $D72C ;Rtn used when list line no.
STROUT EQU $DB3A ;Print string pointed to by (Y,A)
STRPRT EQU $DB3D ;Print string with descriptor
; pointed to by FACMO-FACLO
OUTDO EQU $DB5C ;Applesoft output rtn
FRMNUM EQU $DD67 ;Evaluate expression
GETADR EQU $E752 ;Convert FAC to integer in LINNUM
MOVFM EQU $EAF9 ;Applesoft FP move rtn
LINPRT EQU $ED20 ;Print current line no
LINPRNT EQU $ED24 ;Print decimal no. of (A,X)
PRNTFAC EQU $ED2E ;Print current value of FAC
SETTXT EQU $FB39 ;Switch to text screen
SETTXT1 EQU $FB3C ;Restore normal values of text
; screen
TABV EQU $FB5B ;Position cursor at row in (A)
HOME EQU $FC58 ;Clear text screen
KYIN EQU $FD1B ;Keyboard input rtn
GETLN EQU $FD6F ;Get an input line with no prompt
CROUT EQU $FD8E ;Print carriage return
COUT EQU $FDED ;Print character in (A)
COUT1 EQU $FDF0 ;Output directly to screen
MOVE EQU $FE2C ;Move routine
BELL EQU $FF3A ;Output bell character via CSWL
*
GETBUFR EQU $BEF5 ;Allocate buffer space
FREBUFR EQU $BEF8 ;Free all allocated buffer space
*
***********************************************************
JSR SETTXT ;Print Title and Copyright Notice
JSR HOME
LDA #<ASP
LDX #>ASP
STA TEMP
STX TEMP+1
LDY #$FF
MSG INY
LDA (TEMP),Y
JSR TABV
INY
LDA (TEMP),Y
STA CH
MSG1 INY
LDA (TEMP),Y
BEQ MSG
CMP #$8D
BEQ STARTUP
JSR COUT1
BNE MSG1
*
STARTUP LDA $BF00 ;ProDOS?
CMP #$4C
BNE MOVEUP
JSR FREBUFR ;Yes. Free all alloc. buffer
LDA #14
JSR GETBUFR ;Allocate buffer space
MOVEUP LDX #<START ;DOS 3.3 and ProDOS. Move stepper
LDY #>START ; program to $8C00
STX A1L
STY A1L+1
LDX #<END
LDY #>END
STX A2L
STY A2L+1
LDX #<INSTALL
LDY #>INSTALL
STX A4L
STY A4L+1
LDY #0
JSR MOVE
JMP INSTALL ;Jump to MicroScope program
*
*
ASP DFB 7,10
INV " "
DFB 0
DFB 8,10
INV " MICROSCOPE "
DFB 0
DFB 9,10
INV " "
DFB 0
DFB 12,19
ASC "BY"
DFB 0
DFB 15,14
ASC "ONG TEE YONG"
DFB 0
DFB 20,0
ASC "** COPYRIGHT 1986 MICROSPARC, INC. **"
DFB $8D
START = *
**********************************************************
* INSTALLATION OF EXTENSION TO CHRGET RTN *
**********************************************************
*
ORG $8C00
*
INSTALL LDA #$4C ;Jump instruction
STA AMPER ;Modify & rtn to reinitialize pgm
STA $BA
LDA #<EXTGET ;Modify Applesoft Chrget rtn to
STA $BB ; point to stepper rtn
LDA #>EXTGET
STA $BC
LDA CURLIN ;Current line no. stored here
STA LINNOTMP ;Store current line no. in
LDA CURLIN+1 ;
STA LINNOTMP+1 ; temporary locations
LDA #$FF ;Initialization of various flags
STA STEPFLG ;Stepping mode active
STA PRTFLG ;Current line no. to be printed
LDA #0
STA CONTFLG ;No CONT state
STA NOWLNFLG ;Line no. just executed not
; to be printed
STA AUTOFLG ;Not in autostep mode
LDX #<INSTALL
LDY #>INSTALL
STX AMPER+1 ;& vector pointed to
; reinitialization of pgm
STY AMPER+2
STX TEMP
LDX #0
LDA #0
STA LISTTEMP ;Clear line print flag
LDA #$FF
CLLIN STA LINSAV2,X
INX
CPX #7
BCC CLLIN ;Clear saved line numbers
LDX TEMP
JSR CKPRODOS ;ProDOS?
BEQ PRDS ;Yes. Branch to PRDS
STX HIMEM ;DOS 3.3. Set Himem
STY HIMEM+1
PRDS LDX #<KEYIN ;Change input hook to go to KEYIN
LDY #>KEYIN ; rtn first
STX $38
STY $39
JSR CKPRODOS ;ProDOS?
BEQ PRDS1 ;Yes. Branch to PRDS1
JSR $3EA ;Tell DOS 3.3 of change to
RTS ; input hook
PRDS1 STX $BE32 ;ProDOS current input vector
STY $BE33
JMP $BE00 ;Warm entry to ProDOS BI
*
**********************************************************
* MODIFIED KEYIN RTN *
**********************************************************
*
KEYIN PHA ;Save (A) on stack
LDA PROMPT ;Test prompt to see whether
CMP #$DD ; in immediate mode
BEQ KEYIN1 ;Immediate mode, branch to KEYIN1
PLA ;Program execution mode,
BIT KBDSTRB ; restore (A) from stack and
JMP KYIN ; exit to Normal KEYIN rtn
KEYIN1 PLA
JSR KYIN ;Uses Normal KEYIN rtn for input
*
************************ ;Rtn to resume execution of pgm
; from immediate mode
CMP #$81 ;CTRL-A?
BNE KEYIN2
LDA #255 ;Yes, CTRL-A
STA STEPFLG ;Activate stepping mode
STA PRTFLG ;Activate print line no. mode
STA CONTFLG ;Flag to indicate CONT is active
BIT KBDSTRB
*
CONT LDX #0
CONT1 LDA CONTM,X ;Load CONT into input buffer to
STA $200,X ; be executed by Applesoft
INX
CPX #4
BNE CONT1
LDA #6 ;Store prompt to inform Applesoft
STA PROMPT ; pgm now in execution mode
LDA #$8D ;Exit to Applesoft immediate mode
RTS ; to execute CONT and
; resume pgm execution
*
************************ ;Rtn to list out last six line
; nos. just executed and
; next line no. to be
; executed
KEYIN2 CMP #$84 ;CTRL-D?
BNE KEYIN3
LDA #0 ;Yes, CTRL-D
STA LISTTEMP ;Deactivate listing of whole
; lines
LISTLN LDY #6
LISTLN1 CPY #1
BNE LISTLN2
LDA #$23
JSR COUT
LISTLN2 JSR LINECUR ;List last six lines just
; executed and next line
; to be executed
LDA LISTTEMP ;Rest of line also listed?
BEQ LISTLN3
JSR CROUT ;Yes. Output two carriage returns
JSR CROUT
LISTLN3 LDY TEMPA ;Restore (Y)
DEY
BPL LISTLN1 ;Some more lines to be printed
LDA #$8D ;No more lines to be printed.
RTS ; Exit to immediate mode
*
************************ ;Rtn to list last six lines just
; executed and next line
; to be executed
KEYIN3 CMP #$9A ;CTRL-Z?
BNE KEYIN4
JSR HOME ;Yes, clear text screen
JSR TEXT ;Switch to text screen
LDA #255
STA LISTTEMP ;Activate listing of whole line
BNE LISTLN ;Branch always
*
************************ ;Rtn to list out all the simple
; variables
KEYIN4 CMP #$98 ;CTRL-X?
BEQ VAR
JMP KEYIN5
VAR JSR HOME ;Yes, clear text screen
JSR TEXT ;Switch to text screen
LDA VARTBL ;Store pointer to variable table
STA VRYTBL ; in temporary locations
LDA VARTBL+1
STA VRYTBL+1
VAR1 CMP VAREND+1 ;End of variable table (Hi-byte)?
BNE VAR2 ;No. Continue printing variables
LDA VRYTBL
CMP VAREND ;End of variable table (Lo-byte)?
BNE VAR2 ;No. Continue printing variables
LDA #$8D ;No more variables. Exit to
RTS ; Applesoft immediate mode
*
VAR2 JSR VARNTR ;Format variable name to print
LDA NA ;Print variable name
JSR OUTDO
LDA NA+1
JSR OUTDO
LDA (VRYTBL),Y
CMP #128 ;Determine type of variable
INY
BCC VAR3
LDA #$A5 ;Integer variable.
JSR PRINTEQL ;Print "% ="
INY
INY
JSR PRNTINT ;Print value of integer variable
BEQ VAR5 ;Branch always
*
VAR3 LDA (VRYTBL),Y
CMP #128 ;Determine type of variable
BCC VAR4
LDA #$A4 ;String variable
JSR PRINTEQL ;Print "$ ="
LDA #$A2
JSR COUT ;Print quote
LDA VRYTBL ;Load string descriptor address
CLC
ADC #2 ;Point to correct address
STA FACMO
LDA VRYTBL+1
ADC #0
STA FACLO
JSR STRPRT ;Print string pointed to by FAC
LDA #$A2
JSR COUT ;Print quote
JMP VAR5
*
VAR4 LDA #$A0 ;Real variable
JSR PRINTEQL ;Print "="
LDA VRYTBL ;Load address of real variable
CLC
ADC #2 ;Point to correct address
PHA
LDA #0
ADC VRYTBL+1
TAY
PLA
JSR MOVFM ;Move real variable pointed to by
; (A) and (Y) into FAC
JSR PRNTFAC ;Print value of real variable
*
VAR5 JSR PLACE ;Align display of variables
VAR6 LDA #7 ;Point variable pointer to
JSR INCVTBL ; next variable in table
LDA VRYTBL+1
JMP VAR1 ;Go back to print more variables
*
************************ ;Rtn to list out all arrays
;
KEYIN5 CMP #$96 ;CTRL-V?
BEQ ARY
JMP KEYIN6
ARY JSR HOME ;Yes, clear text screen
JSR TEXT ;Switch to text screen
LDA ARYTBL ;Store pointer to array table in
STA VRYTBL ; temporary work locations
LDA ARYTBL+1
STA VRYTBL+1
ARY1 CMP ARYEND+1 ;End of array table (Hi-byte)?
BNE ARY2 ;No. Continue printing arrays
LDA VRYTBL
CMP ARYEND ;End of array table (Lo-byte)?
BNE ARY2 ;No. Continue printing arrays
LDA #$8D
RTS ;No more arrays to be printed.
; Exit to immediate mode
*
ARY2 LDY #4
LDA (VRYTBL),Y ;Load no. of dimensions of array
STA DIMTMP ; and store in DIMTMP
TAX ; and in (X)
*
ARY3 JSR VARNTR ;Format array name for printing
LDA (VRYTBL),Y
CMP #128 ;Determine type of array
INY
BCC ARY5
*
JSR SETBUF ;Integer array. Set up BUFF
; to print array subscripts
ARY4 LDA #$A5 ;Load (A) with % sign
JSR PRINTNA ;Print name, sign, and subscript
LDY #1
JSR PRNTINT ;Print value of array element
LDA #2 ;Increment array pointer to point
JSR DIM ; to next element of array
; and increment to next
; subscript and see if last
; element reached
BNE ARY4 ;Not last. Continue printing
; integer array
NXTARY JSR CROUT ;Yes, last. Output two carriage
JSR CROUT ; returns
LDA VRYTBL+1
BNE ARY1 ;Branch always to next array
*
ARY5 LDA (VRYTBL),Y
CMP #128 ;String array?
BCC ARY7
JSR SETBUF ;Yes, set up BUFF for printing
; array subscripts
ARY6 LDA #$A4 ;Load (A) with $ sign
JSR PRINTNA ;Print name, sign and subscript
LDA #$A2
JSR COUT ;Print quote
LDA VRYTBL ;Load string descriptor address
STA FACMO
LDA VRYTBL+1
STA FACLO
JSR STRPRT ;Print string
LDA #$A2
JSR COUT ;Print quote
LDA #3 ;Increment array pointer to point
JSR DIM ; to next element and
; increment to next
; subscript and see if last
; element reached
BNE ARY6 ;Not last. Continue printing
BEQ NXTARY ;Yes, last. Go on to next array
*
ARY7 JSR SETBUF ;Real array. Set up input buffer
; for printing subscripts
ARY8 LDA #$A0 ;Load (A) with space
JSR PRINTNA ;Print array name and subscript
LDA VRYTBL ;Load (A) and (Y) with address of
LDY VRYTBL+1 ; element of real array
JSR MOVFM ;Move element of array pointed to
; by (A) and (Y) into FAC
JSR PRNTFAC ;Print value of element of array
LDA #5 ;Increment array pointer to point
JSR DIM ; to next element of array
; and to increment to next
; subscript and see if last
; element reached
BNE ARY8 ;Not last. Continue printing
BEQ NXTARY ;Yes, last. Go on to next array
*
************************ ;Rtn for the setting and removing
; of traps
KEYIN6 CMP #$8C ;CTRL-L?
BEQ TRAP ;Yes, CTRL-L.
JMP KEYIN7
TRAP JSR TEXT ;Switch to text screen
JSR DISTRAP ;Display line nos. trapped
LDA #<TRAPTIT ;Display Trap menu
LDY #>TRAPTIT
JSR STROUT
LDA #$60 ;Print a flashing blank
JSR COUT
DEC CH
TRAP1 LDA KEYBOARD ;Input choice from Trap menu
BPL TRAP1 ;No key pressed. Reread keyboard
BIT KBDSTRB ;Key pressed. Strobe keyboard
CMP #$B1 ;Choice no. 1?
BNE TRAP2
LDX #2 ;Yes, check traps flag to see
KEYTRP LDA TFLG,X ; any traps not used
BNE KEYTRP1 ;Trap used. Next trap flag
STX TEMP ;Trap unused. Save (X) register
LDA #<TRAPSET ;Display TRAPS message
LDY #>TRAPSET
JSR STROUT
JSR GETLN ;Input line no. to be trapped
CPX #0
BEQ KEYTRP2 ;Only <RETURN> key pressed. Exit to
; Applesoft immediate mode
JSR GETNUM ;Convert line no. and
; store it in LINNUM
LDX TEMP ;Restore (X) register to point to
LDA LINNUM ; current trap
STA TRP1,X ;Save Lo-byte of trapped line no.
LDA LINNUM+1
STA TRP2,X ;Save Hi-byte of trapped line no.
LDA #1
STA TFLG,X ;Set trap flag to indicate that
; current trap used
BNE KEYTRP2 ;Branch always to Applesoft
; immediate mode
KEYTRP1 DEX
BPL KEYTRP ;Try next trap flag
LDA #<TRAPFUL ;No free trap. Print
LDY #>TRAPFUL ; "TRAPS FULL" message
JSR STROUT
KEYTRP2 LDX #0
LDA #$8D
RTS ;Exit to Applesoft immediate mode
TRAP2 CMP #$B2 ;Choice no. 2?
BNE TRAP3
LDA #<TRAPRMV ;Yes. Display remove traps
LDY #>TRAPRMV ; message
JSR STROUT
JSR GETLN ;Input line no. to be freed
CPX #0
BEQ KEYRMV2 ;Only <RETURN> key pressed. Exit to
; Applesoft immediate mode
JSR GETNUM ;Convert line no. and
; store it in LINNUM
LDX #2
KEYRMV LDA TFLG,X ;See if any traps used
BEQ KEYRMV1 ;Trap not used. Check next
LDA LINNUM ;Trap used. See if Lo-byte of
CMP TRP1,X ; input line no. same as
; trapped line no.
BNE KEYRMV1 ;Not same. Check next trap flag
LDA LINNUM+1 ;See if Hi-byte of input line
CMP TRP2,X ; no. same as trapped no.
BNE KEYRMV1 ;Not same. Check next trap flag
LDA #0
STA TFLG,X ;Same. Reset trap flag to
; indicate trap now freed
BEQ KEYRMV2 ;Branch always to Applesoft
; immediate mode
KEYRMV1 DEX ;Try next trap flag to see if
BPL KEYRMV ; it is used
KEYRMV2 LDX #0
LDA #$8D
RTS ;Exit to Applesoft immediate mode
*
TRAP3 CMP #$B3 ;Choice no. 3?
BNE TRAP4
LDA #<RMVALL ;Yes, display "ALL TRAPS
LDY #>RMVALL ; REMOVED" message
JSR STROUT
LDX #2
LDA #0 ;Zero out all the trap flags to
DELTRP STA TFLG,X ; indicate all traps free
DEX
BPL DELTRP
LDX #0
LDA #$8D
RTS ;Exit to Applesoft immediate mode
*
TRAP4 CMP #$8D ;Return key?
BEQ TRAPRET ;Yes. Exit trap menu
JMP TRAP1 ;No. Go back to reread keyboard
TRAPRET RTS ;Exit to Applesoft immediate mode
*
************************ ;Rtn to switch to text screen
KEYIN7 CMP #$86 ;CTRL-F?
BNE KEYIN8
JSR TEXT ;Yes, switch to text screen
LDA #$8D
RTS ;Exit to immediate mode
*
************************ ;Rtn to switch to Hires page 1
KEYIN8 CMP #$92 ;CTRL-R?
BNE KEYIN9
JSR HIRES1 ;Yes, switch to Hires page 1
LDA #$8D
RTS ;Exit to immediate mode
*
************************ ;Rtn to switch to Lores page 1
KEYIN9 CMP #$87 ;CTRL-G?
BNE KEYIN10
JSR LORES ;Yes, switch to Lores page 1
LDA #$8D
RTS ;Exit to immediate mode
*
************************ ;Rtn to switch to Hires page 2
KEYIN10 CMP #$94 ;CTRL-T?
BNE KEYIN11
JSR HIRES2 ;Yes, Switch to Hires page 2
LDA #$8D
RTS ;Exit to immediate mode
*
************************ ;Rtn to restore normal Applesoft
; Chrget code
KEYIN11 CMP #$8F ;CTRL-O?
BNE KEYRET
LDA #$C9 ;Yes, restore Chrget rtn to its
STA $BA ; original code
LDA #$3A
STA $BB
LDA #$B0
STA $BC
LDX #<KYIN ;Restore normal KEYIN Hook
LDY #>KYIN
STX $38
STY $39
JSR CKPRODOS ;ProDOS?
BEQ KEYRET1 ;Yes. Branch to KEYRET1
JSR $3EA ;Tell DOS 3.3 of change in
; KEYIN Hook
KEYRET2 LDX #0
LDA #$8D ;Issue carriage return
KEYRET RTS ;Exit to Applesoft immediate mode
KEYRET1 STX $BE32 ;ProDOS current input vector
STY $BE33
BEQ KEYRET2 ;Branch always
*
*
*
**********************************************************
* MODIFIED CHRGET RTN *
**********************************************************
*
EXTGET STA AHOLD ;Save (A)
STX XREG ;Save (X)
STY YREG ;Save (Y)
PHP ;Push status register (P) onto
PLA ; stack before saving (P)
STA STATUS ; into STATUS location
*
LDA $B9 ;Applesoft in immediate or
CMP #$8 ; program execution mode?
BCS EXTGET1 ;Applesoft in pgm execution mode,
; continue with EXTGET1 rtn
JMP IGNOR ;Applesoft in immediate mode,
; exit to CHRGET at IGNOR
*
EXTGET1 LDA CONTFLG ;Program just resumed execution?
BEQ EXTGET2
LDX #0 ;Yes. Deactivate CONTFLG
STX CONTFLG
RESTSCN LDA SVTXT1,X ;Restore text screen to state
STA 1024,X ; just before break in
LDA SVTXT2,X ; program execution
STA 1280,X
LDA SVTXT3,X
STA 1536,X
LDA SVTXT4,X
STA 1792,X
DEX
BNE RESTSCN
LDX #3 ;Restore text window to state
WNDA LDA WNDTMPRY,X ; just before break in
STA WNDS,X ; program execution
DEX
BPL WNDA
LDA CHTEMP ;Restore cursor to location just
STA CH ; before break in program
LDA CVTEMP ; execution
JSR TABV
JMP PRNLN ;Jump to print the program line
*
EXTGET2 LDA KEYBOARD ;Read keyboard
CMP #$81 ;CTRL-A?
BNE EXTGET5
LDA AUTOFLG ;Yes. Is auto line printing
; mode active?
BNE EXTGET5 ;Yes. Program not allowed to halt
LDA CURLIN ;No, not active. Check Lo-byte of
CMP LINNOTMP ; CURLIN to see if Applesoft
; still executing same line
BNE EXTGET3 ;No, Applesoft executing a new
; line. Pgm allowed to halt
LDA CURLIN+1 ;Applesoft still executing the
CMP LINNOTMP+1 ; same line?
BNE EXTGET3 ;No. Program allowed to halt
JMP IGNOR ;Yes. Exit to CHRGET at IGNOR
EXTGET3 JSR SAVLIN ;Save last six executed line nos.
; and current line no.
; to be executed
EXTGET4 BIT KBDSTRB ;Clear keyboard strobe
LDA CH
STA CHTEMP ;Save horizontal cursor position
LDA CV
STA CVTEMP ;Save vertical cursor position
LDX #3
WNDB LDA WNDS,X ;Save current state of text
STA WNDTMPRY,X ; window into temporary
DEX ; locations
BPL WNDB
*
LDX #0 ;Save text screen in temporary
SVSCN LDA 1024,X ; area following user
STA SVTXT1,X ; requested break in program
LDA 1280,X ; execution
STA SVTXT2,X
LDA 1536,X
STA SVTXT3,X
LDA 1792,X
STA SVTXT4,X
DEX
BNE SVSCN
*
LDA CURLIN ;Store line no. at which program
STA OLDLIN ; execution halted in OLDLIN
LDA CURLIN+1
STA OLDLIN+1
JSR SETTXT1 ;Restore text screen to normal
; values and place cursor
; at bottom of screen
JSR CROUT
LDX $F8 ;Stop execution of program when
TXS ; CTRL-A pressed and exit to
JMP PGMSTP ; Applesoft immediate mode
*
EXTGET5 CMP #$97 ;CTRL-W?
BNE EXTGET6
LDA #255 ;Yes. Activate following flags
STA STEPFLG ;Stepping mode active
STA PRTFLG ;Line no. print active
LDA #0
STA AUTOFLG ;No Auto line stepping mode
*
EXTGET6 LDA CURLIN ;Applesoft still executing the
CMP LINNOTMP ; same line?
BNE EXTGET7
LDA CURLIN+1
CMP LINNOTMP+1
BNE EXTGET7
JMP IGNOR ;Yes. Exit to CHRGET at IGNOR
*
EXTGET7 JSR SAVLIN ;No. Save last six executed line
; nos. and current line no.
; to be executed
LDX #2
TRAPS LDA TFLG,X ;Check current line no. to see
BEQ TRAPS1 ; if it has been trapped
LDA TRP1,X
CMP CURLIN
BNE TRAPS1
LDA CURLIN+1
CMP TRP2,X
BNE TRAPS1
JSR BELL ;Line no. trapped, sound bell
LDX #255 ; and activate stepping mode
STX STEPFLG
INX
STX AUTOFLG
BNE EXTGET8 ; and branch to EXTGET8
TRAPS1 DEX
BPL TRAPS
*
EXTGET8 LDA STEPFLG ;Stepping mode active?
BNE PRNLN
JMP IGNOR ;No, Exit to CHRGET at IGNOR
*
PRNLN LDA INVFLG ;Yes. Save current screen output
STA VIDEOTMP ; mode (normal, inverse or
; flashing)
LDA CH
STA CHTEMP ;Save horizontal cursor position
LDA CV
STA CVTEMP ;Save vertical cursor position
*
STORE LDX #39 ;Save last four lines of text
STORE1 LDA $650,X ; screen into temporary
STA SVTX1,X ; locations
LDA $6D0,X
STA SVTX2,X
LDA $750,X
STA SVTX3,X
LDA $7D0,X
STA SVTX4,X
DEX
BPL STORE1
*
MODE LDA PRTFLG ;Print line no. flag active?
BEQ WAITKEY ;No. Skip printing of line
*
PRBLK LDA #$20 ;Yes. Blank out last four lines
LDX #39 ; of text screen with
PRBLK1 STA $650,X ; inverse spaces
STA $6D0,X
STA $750,X
STA $7D0,X
DEX
BPL PRBLK1
*
LDA #$3F ;Line to be printed in inverse
STA INVFLG
LDA WNDTOP ;Save current top line of
STA WNDTMP ; text window
LDA #0 ;Place cursor at beginning of
STA CH ; line
LDA #20 ;Set current top line of text
STA WNDTOP ; window to line 21
JSR TABV
*
LDA #$F0 ;Disconnect DOS hook. Restore
STA $36 ; character output switch
LDA #$FD ; (CSW) to point to COUT1.
STA $37 ; This is to enable program
; to step through DOS
*
LDA NOWLNFLG ;Current line or line which has
; just executed to be
; printed?
BEQ PRNXT ;Current line to be executed to
; be printed.
; Branch to PRNXT
JSR NOWLIN ;Line which has just executed to
; be printed. Call NOWLIN
BEQ AUTOSTP ;Branch always to AUTOSTP
*
PRNXT JSR LINPRT ;Print line no. of current line
LDA #$A0 ;Print space between line no.
JSR COUT ; and line statement
JSR PRNTLN ;Print rest of current line
; to be executed
*
AUTOSTP LDX $9D04 ;Reconnect DOS hook into CSW
LDY $9D05
JSR CKPRODOS ;ProDOS?
BNE AUTOSTPZ ;No
LDX $BE34 ;Yes. BI's output intercept
LDY $BE35 ; address
AUTOSTPZ STX $36 ;DOS hook reconnected into CSW
STY $37
AUTOSTP0 LDA WNDTMP ;Restore current top line of
STA WNDTOP ; text window
LDA AUTOFLG ;Auto-stepping mode active?
BEQ WAITKEY
LDA CONTSPED ;Yes. Speed of auto-stepping mode
; zero (fastest) ?
BEQ WAITKEY2 ;Yes. Do not wait
AUTOSTP1 TAX ;No. Wait
AUTOSTP2 JSR $FCA8 ;Call waiting subroutine
LDY KEYBOARD ;Read keyboard
CPY #$97 ;CTRL-W ?
BEQ AUTOSTP3 ;Yes. Exit waiting loop
DEX ;No. Continue waiting until
BNE AUTOSTP2 ; (X) decreases to zero
AUTOSTP3 JMP REST ;Exit waiting loop
*
WAITKEY BIT KBDSTRB ;Clear keyboard strobe
WAITKEY1 LDA KEYBOARD ;Read keyboard
BPL WAITKEY1 ;No key pressed. Reread keyboard
CMP #$85 ;CTRL-E?
BNE GET1
LDA #0 ;Yes. Deactivate stepping mode
STA STEPFLG
WAITKEY2 JMP REST ; and jump to REST
*
*
GET1 CMP #$9B ;ESC?
BNE GET2
LDA PRTFLG ;Yes. Activate or deactivate
; line printing mode?
BNE ESC ;Line printing mode active.
; Branch to ESC
LDA #$FF ;Line printing mode not active.
STA PRTFLG ; Activate it and jump back
JMP PRBLK ; to print line
ESC JSR RESTORE ;Restore last four lines of
; screen to normal
LDA #0
STA PRTFLG ;Deactivate line printing mode
BEQ WAITKEY ;Branch always to reread keyboard
*
GET2 CMP #$91 ;CTRL-Q?
BNE GET3
LDA NOWLNFLG ;Yes. Toggle between printing of
; line which has just
BNE CTRLQ ; executed and line to be
LDA #255 ; executed
BNE CTRLQ1
CTRLQ LDA #0
CTRLQ1 STA NOWLNFLG
JMP MODE ;Jump back to MODE where line
; will be printed if
; PRTFLG active
*
GET3 CMP #$86 ;CTRL-F?
BNE GET4
JSR TEXT ;Yes. Switch to text screen
BCS WAITKEY ;Branch always to reread keyboard
GET4 CMP #$92 ;CTRL-R?
BNE GET5
JSR HIRES1 ;Yes. Switch to Hires page 1
BCS WAITKEY ;Branch always to reread keyboard
GET5 CMP #$94 ;CTRL-T?
BNE GET6
JSR HIRES2 ;Yes. Switch to Hires page 2
BCS WAITKEY ;Branch always to reread keyboard
GET6 CMP #$87 ;CTRL-G?
BNE GET7
JSR LORES ;Yes. Switch to Lores page 1
BCS WAITKEY ;Branch always to reread keyboard
*
GET7 CMP #$81 ;CTRL-A?
BNE GET8
JSR RESTR ;Yes. restore the last four lines
; of text screen, horizontal
; and vertical cursor
; position and INVFLG
JMP EXTGET4 ;Jump back to halt pgm execution
*
GET8 CMP #$84 ;CTRL-D?
BNE REST
BIT KBDSTRB ;Yes. Clear keyboard strobe
ATOSTEP LDA KEYBOARD ;Read keyboard
BPL ATOSTEP ;No key pressed. Reread keyboard
BIT KBDSTRB ;Key pressed. Strobe keyboard
CMP #$B0 ;Less than '0'?
BCC ATOSTEP2 ;Yes. Branch to ATOSTEP2
CMP #$BA ;No. Greater than '9'?
BCS ATOSTEP2 ;Yes. Branch to ATOSTEP2
AND #$0F ;No. Convert to binary
ASL ;Double the binary number
CMP #18 ;Binary number 18?
BNE ATOSTEP1 ;No. Branch to ATOSTEP1
LDA #50 ;Yes. Change it to 50
ATOSTEP1 STA CONTSPED ;Store binary number in CONTSPED
ATOSTEP2 LDA #255
STA AUTOFLG ;Activate auto-stepping mode
*
*
REST JSR RESTR ;Restore last four lines of Text
; screen, horizontal and
; vertical cursor position
; and state of INVFLG
*
IGNOR LDA STATUS
PHA
LDX XREG ;Restore (X)
LDY YREG ;Restore (Y)
PLP ;Restore status register (P)
*
LDA AHOLD ;Restore (A)
CMP #':
BCS IGNOR1
JMP $BE
IGNOR1 RTS ;Exit to CHRGET
*
*
*
**********************************************************
* VARIOUS SUBROUTINES *
**********************************************************
*
************************ ;Rtn to restore the last four
; lines of text screen,
; horizontal and vertical
; cursor position and INVFLG
RESTR JSR RESTORE ;Restore last four lines of text
; screen to normal
LDA CHTEMP ;Restore horizontal cursor
STA CH ; position
LDA CVTEMP
JSR TABV ;Restore vertical cursor position
LDA VIDEOTMP
STA INVFLG ;Restore INVFLG to original state
RTS
*
************************ ;Rtn to restore the last four
; lines of text screen
RESTORE LDX #39
RESTORE1 LDA SVTX1,X
STA $650,X
LDA SVTX2,X
STA $6D0,X
LDA SVTX3,X
STA $750,X
LDA SVTX4,X
STA $7D0,X
DEX
BPL RESTORE1
RTS
*
************************ ;Rtn to save last six executed
; line nos. and current line
; no. to be executed
SAVLIN LDX #5
SAVLIN1 LDA LINSAV1,X ;Each time a new line is
LDY LINSAV2,X ; executed, the last six
INX ; line nos. are shifted
STA LINSAV1,X ; successively up and the
TYA
STA LINSAV2,X
DEX
DEX
BPL SAVLIN1
INX
LDA CURLIN ; current line no. is saved
STA LINSAV1,X ; at the bottom of the
STA LINNOTMP ; reserved storage locations
LDA CURLIN+1 ; and in LINNOTMP
STA LINSAV2,X
STA LINNOTMP+1
RTS
*
************************ ;Rtn to print line just executed
NOWLIN LDA #255
STA LISTTEMP ;Activate flag to indicate whole
; line to be printed
LDA #$A3 ;Print "#" sign before printing
JSR COUT ; rest of line
LDY #1 ;Go on to LINECUR rtn
*
************************ ;Rtn to print out whole line
; or only the line no.
; depending on state of
; LISTTEMP flag
LINECUR LDX LINSAV1,Y ;Load (X) and (A) with line no.
STX LINNUM
LDA LINSAV2,Y ; and also save it in LINNUM
CMP #$FF ;empty, don't print it
BEQ LINECUR2
STA LINNUM+1 ; to be used by FINDLIN to
; locate line
STY TEMPA ;Save the (Y) register
LLCUR JSR LINPRNT ;Print out line no.
LDA #$A0
JSR COUT ;Print a blank space
LDA LISTTEMP ;Rest of line to be printed?
BEQ LINECUR1
JSR PRNTLN1 ;Yes. Print out rest of line
LINECUR1 RTS
LINECUR2 LDX #0
LDA #$8D
STA BUFF ;clear input buffer
TXA ;put zero in A
STY TEMPA ;save Y
RTS
*
************************ ;Rtn to print out rest of line
PRNTLN LDA CURLIN
STA LINNUM
LDA CURLIN+1
STA LINNUM+1
PRNTLN1 JSR FINDLIN ;Get starting address of line
LDY #4
PRNTLN2 LDA (LOWTR),Y ;End of line reached?
BEQ PRNTLN3 ;Yes. Return to calling rtn
BMI EVTOKEN ;No. Hi-bit set.
; Branch to EVTOKEN
JSR OUTDO ;Hi-bit not set. Print character
INY ;Point to next byte of current
; line
BNE PRNTLN2 ;Branch always
PRNTLN3 RTS
*
EVTOKEN SEC ;Modified Applesoft list rtn
SBC #$7F
TAX
STY $85
LDY #$D0
STY $9D
LDY #$CF
STY $9E
LDY #$FF
INCPNTR DEX
BEQ TKNFND
INCPNTR1 JSR INCPTR
BPL INCPNTR1
BMI INCPNTR
TKNFND LDA #$A0 ;Print space followed by
JSR COUT
TKNPRNT JSR INCPTR
BMI TKNPRNT1
JSR OUTDO ; Applesoft token word
BNE TKNPRNT
TKNPRNT1 JSR OUTDO
LDA #$A0
JSR COUT
LDY $85
INY
BNE PRNTLN2 ;Branch always
*
************************ ;Rtn to display the Trap menu and
; display the line nos.
; which have been trapped
DISTRAP LDA #<TRAPDISP ;Display the Trap menu when
LDY #>TRAPDISP ; CTRL-K pressed
JSR STROUT
LDY #2
DISTRAP1 LDA TFLG,Y ;Display line nos. which have
BEQ DISTRAP2
LDA TRP2,Y ; been trapped
LDX TRP1,Y
STY TEMP
JSR LINPRNT
LDA #$A0 ;Print a blank space
JSR COUT
LDY TEMP
DISTRAP2 DEY
BPL DISTRAP1
RTS
*
************************ ;Rtn to convert input line no.
; and place it in LINNUM
GETNUM JSR GDBUFS ;Put zero at end of input buffer
; and mask off most
; significant bit on
; all bytes
LDA #0 ;Re-point TXTPTR to start of
STA TXTPTR ; input buffer
LDA #2
STA TXTPTR+1
JSR FRMNUM ;Evaluate line no. stored in
; input buffer and put the
; result in FAC
JSR GETADR ;Convert FAC to two-byte integer
; and store it in LINNUM
RTS
*
************************ ;Rtn to increase variable or
; array pointer to point to
; start of variable or array
INCVTBL CLC
ADC VRYTBL
STA VRYTBL
BCC INCVTBL1
INC VRYTBL+1
INCVTBL1 RTS
*
************************ ;Rtn to print " = " during
; listing of variables
; and arrays
PRINTEQL JSR COUT
LDA #$A0
JSR COUT ;Print a space
LDA #$BD
JSR COUT ;Print the "=" sign
LDA #$A0
JSR COUT ;Print a space
RTS
*
************************ ;Rtn to format the variable and
; array name for printing
; to screen
VARNTR LDY #1
LDA (VRYTBL),Y ;Name single or double lettered?
AND #$7F ;Zero out the hi-bit
BNE VARBL ;Double-lettered name
LDA #$A0 ;Single-lettered name. Second
; letter filled with space
VARBL STA NA+1 ;Store variable or array name in
DEY ; NA before printing it out
LDA (VRYTBL),Y
STA NA
RTS
*
************************ ;Rtn to print value of integer
; variable or array
PRNTINT LDA (VRYTBL),Y
TAX ;Load (X) with hi-byte of integer
DEY
LDA (VRYTBL),Y ;Load (A) with lo-byte of integer
JSR LINPRNT ;Print value of the integer
RTS
*
************************ ;Rtn to align the listing of the
; variables and arrays into
; two columns
PLACE LDA #20
CMP CH
STA CH
BCS PLACE1
JSR CROUT ;Length of previous variable or
; array element too long.
; Position current variable
; or array element to be
; printed on a new line
PLACE1 RTS
*
************************ ;Rtn to set up buffer for the
; printing of array
; subscripts
SETBUF LDA #5 ;Increment array pointer to point
JSR INCVTBL ; to the table of array
; dimensions
LDA VRYTBL ;Store address of the table
STA PTR ; of array dimensions
LDA VRYTBL+1 ; in PTR
STA PTR+1
*
LDY #0
SETBUF1 LDA #0 ;Initialize to zero the bottom
STA BUFF,Y ; part of BUFF to be used in
INY ; printing array subscripts
STA BUFF,Y
INY
LDA #2 ;Increment array pointer to point
JSR INCVTBL ; to actual start of array
DEX
BNE SETBUF1
RTS
*
************************ ;Rtn to print out the name and
; subscript of array element
PRINTNA STA NA+2 ;Store sign for the type of array
LDY #>NA
LDA #<NA ;Print name of array element
JSR STROUT ; followed by "("
*
LDA DIMTMP ;Load (A) with no. of dimensions
ASL ; of array and times by two
TAY ; and store it in (Y) to be
; used as counter
PRINTNA1 DEY
LDA BUFF,Y ;Load (X) and (A) with particular
TAX ; subscript of current
; element of array
DEY
STY TEMP
LDA BUFF,Y
JSR LINPRNT ;Print subscript of array element
LDY TEMP
BEQ PRINTNA2 ;Branch if no more subscripts of
; current array element to
; be printed
LDA #"," ;Print comma within subscript of
JSR COUT ; multidimensional array
BNE PRINTNA1 ;Branch always to print rest of
; array subscript
PRINTNA2 LDA #")"
JSR PRINTEQL ;Print ") = "
RTS
*
************************ ;Rtn to align printing of array
; and see if last element of
; array printed
DIM JSR INCVTBL ;Increment array pointer to point
; to next element of array
JSR PLACE ;Align printing of array
*
LDA DIMTMP ;Load (A) with no. of dimensions
ASL ; of array ,multiply by two
TAY ; and store it in (Y) to be
; used as counter
DIM1 DEY
LDA BUFF,Y ;Store the size of subscript plus
STA TMP+1 ; one in TMP and TMP+1 to be
DEY ; used for comparison in
LDA BUFF,Y ; incrementing subscript
STA TMP
INC TMP+1
BNE DIM2
INC TMP
DIM2 LDA TMP ;Compare current subscript to see
CMP (PTR),Y ; if it has reached its
BNE DIM3 ; dimensioned size. If not
INY ; then branch to increment
LDA TMP+1 ; subscript
CMP (PTR),Y
BNE DIM4
*
LDA #0 ;Reset to zero any particular
STA BUFF,Y ; subscript which has
DEY ; execeeded its dimensioned
STA BUFF,Y ; size
BNE DIM1
RTS
*
DIM3 INY ;Increment subscript stored in
DIM4 TYA ; BUFF
TAX
INC BUFF,X
BNE DIM5
DEX
INC BUFF,X
DIM5 RTS
*
************************ ;Rtn to switch to text screen
TEXT BIT $C054
BIT $C051
RTS
*
************************ ;Rtn to switch to Lores page 1
LORES BIT $C054
BIT $C056
BIT $C050
RTS
*
************************ ;Rtn to switch to Hires page 1
HIRES1 BIT $C054
BIT $C050
BIT $C057
RTS
*
************************ ;Rtn to switch to Hires page 2
HIRES2 BIT $C050
BIT $C057
BIT $C055
RTS
*
************************ ;Rtn to check whether ProDOS is
; active
CKPRODOS LDA $BF00 ;For ProDOS, location $BF00
CMP #$4C ; contains the value $4C
RTS
*
*
**********************************************************
* VARIOUS MESSAGES AND RESERVED LOCATIONS USED BY PROGRAM*
**********************************************************
CONTM ASC "CONT"
*
TRAPDISP ASC "TRAPS: "
HEX 00
TRAPSET ASC " SET? "
HEX 00
TRAPRMV ASC " REMOVE? "
HEX 00
TRAPFUL ASC " TRAPS FULL"
HEX 00
RMVALL ASC " ALL TRAPS REMOVED"
HEX 00
TRAPTIT HEX 0D,0D
ASC "1. SET TRAP 2. REMOVE A TRAP "
ASC "3. REMOVE ALL TRAPS OR PRESS RETURN "
HEX 0D,00
*
WNDTMPRY DFB 0,40,0,24
*
CONTSPED DFB 8
*
LINSAV1 HEX 00,00,00,00,00,00,00
LINSAV2 HEX 00,00,00,00,00,00,00
*
TRP1 HEX 00,00,00
TRP2 HEX 00,00,00
TFLG HEX 00,00,00
*
NA HEX 00,00,00
DFB $A8,0
*
TMP DS 2
DIMTMP DS 1
*
SVTXT1 = *
SVTX1 DS 40
SVTX2 DS 40
SVTX3 DS 40
SVTX4 DS 40
DS 96
SVTXT2 DS 256
SVTXT3 DS 256
SVTXT4 DS 256
*
*
END1 = *
END = START+END1-INSTALL